package day23;

public class PrintNumberChar {
	public static void main(String[] args) {
		Object o = new Object();
		Thread t1 = new NumberThread(o);
		Thread t2 = new CharThread(o);
		t1.start();
		t2.start();
	}
}

class NumberThread extends Thread {
	private Object o;

	public NumberThread(Object o) {
		this.o = o;
	}

	public void run() {
		synchronized (o) {
			try {
				for (int i = 1; i <= 26; i++) {
					System.out.println(i * 2 - 1);
					System.out.println(i * 2);
					o.notifyAll();
					if (i != 26) {
						o.wait();
					}
				}
			} catch (Exception e) {
			}
		}
	}
}

class CharThread extends Thread {
	private Object o;

	public CharThread(Object o) {
		this.o = o;
	}

	public void run() {
		synchronized (o) {
			try {
				for (char c = 'A'; c <= 'Z'; c++) {
					System.out.println(c);
					o.notifyAll();
					if (c != 'Z') {
						o.wait();
					}
				}
			} catch (Exception e) {
			}
		}
	}
}
